package pl.project.engineering.pages;

import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;
import pl.project.engineering.entities.AlertEmailAddress;
import pl.project.engineering.services.AppConfig;

/**
 *
 * @author iKrzysiek
 */
@RequiresAuthentication
public class CreateAlertAddressEmail {

  @Property
  private AlertEmailAddress emailAddress;

  @Inject
  private AppConfig appConfig;

  @InjectPage
  private Configuration configuration;
  
  @RequiresAuthentication
  Object onActivate(){
    return null;
  }

  Object onSuccess() {
    appConfig.getAlertEmailAddressList().addAlertEmailAddress(emailAddress);
    appConfig.SaveConfigFile();
    return configuration;
  }
}
